import { createRouter, createWebHistory } from 'vue-router'
import Layout from "@/views/Layout.vue";
import Home from "@/views/Home/index.vue";
import Category from "@/views/Category/index.vue";
import Cart from "@/views/Cart/index.vue";
import User from "@/views/User/index.vue";


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'layout',
      component: Layout,
      redirect: '/home',
      children: [
        {
          path: '/home',
          name: 'home',
          component: Home
        },
        {
          path: '/category',
          name: 'category',
          component: Category,

          // 分类页面收搜框
          // children: [
          //   {
          //     path: '/categorySearch',
          //     name: 'categorySearch',
          //     component: () => import('@/components/categorySearch.vue')

          //   }
          // ]
        },
        {
          path: '/cart',
          name: 'cart',
          component: Cart,
          meta:{
            requireAuth:true  // 判断是否需要登录
          }

        },
        {
          path: '/user',
          name: 'user',
          component: User
        }
      ]
    },
    // 分类页面收搜框
    {
      path: '/categorySearch',
      name: 'categorySearch',
      component: () => import('@/components/categorySearch.vue')

    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/Login/index.vue')
    },
    {
      path: '/register',
      name: 'register',
      component: () => import('@/views/Register/index.vue')
    },
    {

			path: '/search',
			name: 'search',
			component: () => import('@/views/Search/index.vue')
		},
    {
			path: '/customer',
			name: 'customer',
			component: () => import('@/views/customer/index.vue')
		},
    {
			path: '/detail/:id',
			name: 'detail',
			component: () => import('@/views/Detail/detail.vue')
		},
    {
			path: '/categorydetail/:id',
			name: 'categorydetail',
			component: () => import('@/views/Detail/categorydetail.vue')
		},
    {
			path: '/results',
			name: 'results',
			component: () => import('@/views/Search/results.vue')
		},
    {
			path: '/address',
			name: 'address',
			component: () => import('@/views/Address/index.vue')
		},
    {
			path: '/submit',
			name: 'submit',
			component: () => import('@/views/Submit/index.vue')
		},
  ]
})

export default router
